// 这里需要假设已经完成了 loadFile 和 该文件的加载
class Base {
    static getBaseIns(lf,fp) {
        let base = new Base();
        base._load(lf,fp)
            .then(() => {
                DomUtils.OnResize();
                window.layoutSlider = new LayoutSlider(window.loading);
                new MouseSlider(window.layoutSlider);
                ClockClass.apply(window.layoutSlider);
                let cardInner = new Card(window.layoutSlider,200,'cardListInner');
                let cardOuttr = new Card(window.layoutSlider,200,'cardListOutter');
                window.layoutSlider.fetchPages()
                    .then(() => {
                        window.loading.hide();
                    });
                // window.loading.hide();
                // window.layout = Layout.apply();
                // ShowItems.apply(window.layout);
            });
        return base;
    }
    constructor() {
        this.js = [
            // {
            //     link: './../base/utils/requests.js',
            //     text: 'requests.js',
            // },
            {
                link: './../base/bass.css',
                text: 'bass.css',
            },
            {
                link: './../base/animate/animated-border.min.css',
                text: 'animated-border.min.css'
            },
            {
                link: './../base/clock/clock.css',
                text: 'clock.css'
            },
            {
                link: './../base/loading/loading.css',
                text: 'loading-css',
            },
            {
                link: './../base/icons/icon.css',
                text: 'icon.css',
            },
            {
                link: './../base/loading/Loading.js',
                text: 'Loading JS',
            },
            // {
            //     link: './../base/firstPage/firstPageAddon.js',
            //     text: 'firstPageAddon'
            // },
            {
                link: './../base/utils/domUtils.js',
                text: 'domUtils'
            },
            {
                link: './../base/utils/otherUtils.js',
                text: 'otherUtils'
            },
            {
                link: './../base/Slider/jquery.1.2.6.js',
                text: 'jQuery'
            },
            {
                link: './../base/Slider/jquery.jparallax.js',
                text: 'jquery.jparallax.js'
            },
            // {
            //     link: './../base/Slider/Slider.css',
            //     text: 'Slider-Css'
            // },
            // {
            //     link: './../base/Slider/Slider.js',
            //     text: 'Slider-Js'
            // },
            {
                link: './../base/Slider/MouseSlider.js',
                text: 'MouseSlider.js'
            },
            {
                link: './../base/LayoutSlider/LayoutSlider.js',
                text: 'LayoutSlider.js'
            },
            {
                link: './../base/clock/ClockClass.js',
                text: 'ClockClass.js'
            },
            {
                link: './../base/clock/moment.min.js',
                text: 'moment.min.js'
            },
            {
                link: './../base/card/Card.js',
                text: 'Card.js'
            },
            // {
            //     link: './../base/layout/layout.js',
            //     text: 'layout'
            // },
            // {
            //     link: './../base/layout/ShowItems.js',
            //     text: 'ShowItems'
            // },
        ];
    }
    _load(lf,fp) {
        let next = _ => _();
        let pre = _ => _;
        return new Promise(s => {
            lf.addFile(this.js)
                .load(function (o) {
                    if (o.start) {
                        pre(o);
                    } else {
                        if (o.over) {
                            // window.firstPage.over();
                            console.log('load over');
                            setTimeout(s,500)
                        } else if (o.file.text === 'Loading JS') {
                            window.loading = new Loading();
                            pre = o => {
                                window.loading.setLoadingText(`Load File : ${o.file.link}`);
                            }
                            next = n => {
                                // n();
                                setTimeout(n,500);
                            }
                        } /* else if (o.file.text === 'firstPageAddon') {
                            window.firstPage = FirstPageAddon.apply(fp);
                            pre = o => {
                                window.firstPage.addText(`[加载]&nbsp;&nbsp;` + o.file.text,`[完成]&nbsp;&nbsp;` + o.file.text);
                            };
                            next = n => {
                                n();
                                // setTimeout(n,500);
                            }
                        }*/
                        next(o.next)
                    }
                });
        })
    }
}
